/**
 * 接口
 */
interface Person {
  username:string;
  age:number;
}

let steak:Person = {
  username:'steak',
  age:22,
};

/**
 * 接口属性可选
 */
interface People {
  username:string,
  age?:number, //可有可无 (?)
}

let steak2:People = {
  username:'steak',
  age:23,
};

/**
 * 任意属性
 */
interface Teacher {
  username:string,
  age?:number,
  [prop:string]:any
}

let steak3:Teacher = {
  username:'steak',
  sex:'男',
};
steak3.username = 'liupai';

/**
 * 只读属性 （readonly）
 */
interface Cat {
  readonly name:string,
  color:string,
  age?:number,
}

let cat:Cat = {
  name:'mimi',
  color:'yellow',
};
//cat.name = "3434" //只能读，不能修改

/**
 * 实现接口
 */
class BlueBat implements Cat{
  color: string = '蓝猫';
  readonly name: string;
  age:number = 12;
  constructor(){

  }
}

/**
 * new一个对象
 */
let blueCat = new BlueBat();
console.log(blueCat.age);

